package com.example;

import com.example.dal.entity.DemoAuthor;
import com.example.dal.mapper.DemoAuthorMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.sql.Date;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

/**
 * @Author: flen
 * @Date: 2018/12/18 10:42
 */
public class AppSandalone {

	public static void main(String[] args) throws IOException {
		InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);

		SqlSession sqlSession = sqlSessionFactory.openSession();

		DemoAuthorMapper demoAuthorMapper = sqlSession.getMapper(DemoAuthorMapper.class);
		LocalDateTime date = LocalDateTime.now();
		DemoAuthor author1 = new DemoAuthor(null,"xiaoming", date, date);
		demoAuthorMapper.insert(author1);
		sqlSession.commit();

		sqlSession.close();

	}
}
